from pyspark.sql import SparkSession
from pyspark.sql import Row

spark = SparkSession.builder.appName("demo").enableHiveSupport().getOrCreate()
# spark.sql("CREATE TABLE IF NOT EXISTS demo (key INT, value STRING) USING hive")
Record = Row("key", "value")
recordsDF = spark.createDataFrame([Record(i, "val_" + str(i)) for i in range(1, 10)])
recordsDF.createOrReplaceTempView("records")

# spark.sql("CREATE TABLE IF NOT EXISTS demo SELECT * FROM records")
spark.sql("INSERT OVERWRITE TABLE demo SELECT * FROM src")
spark.sql("SELECT * FROM demo").show()
